package org.example.test2;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class main {
    //2.使用字符流完成文件的复制(文件路径和内容自定义)
    public static void main(String[] args) {
        String sourceFilePath = "src/source.txt";
        String targetFilePath = "target.txt";

        try (FileReader reader = new FileReader(sourceFilePath);
             FileWriter writer = new FileWriter(targetFilePath)) {

            int character;

            while ((character = reader.read()) != -1) {
                writer.write(character);
            }

            System.out.println("文件复制完成。");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
